﻿// Copyright 2010 Maxime Serrano <lastchronicler@gmail.com>
// Copyright 2009, 2010 Matvei Stefarov <me@matvei.org>
using System;
using System.Text;
using System.Net;

namespace ForgeCraft
{
    public sealed class SignInfo
    {
        public const int fieldCount = 7;

        public string location;
        public DateTime createdDate;
        public string createdBy;
        public string text1;
        public string text2;
        public string text3;
        public string text4;

        // === Serialization & Defaults =======================================
        // fabricate info for a player
        public SignInfo()
        {
            location = "-";
            createdDate = DateTime.UtcNow;
            createdBy = "-";
            text1 = "";
            text2 = "";
            text3 = "";
            text4 = "";
        }

        // load info from file
        public SignInfo(string[] fields)
        {
            location = fields[0];

            createdDate = DateTime.Parse(fields[1]);
            createdBy = fields[2];

            text1 = fields[3];
            text2 = fields[4];
            text3 = fields[5];
            text4 = fields[6];
        }


        // save to file
        public string Serialize()
        {
            string[] fields = new string[fieldCount];

            fields[0] = location;
            fields[1] = createdDate.ToString();
            fields[2] = createdBy;
            fields[3] = text1;
            fields[4] = text2;
            fields[5] = text3;
            fields[6] = text4;

            return String.Join(",", fields);
        }


        // === Updating =======================================================

        // update information
        public void SignSet()
        {
            //TODO: Probably needs something important here.

        }
    }
}